<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- 首单返券管理页 -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <title>e网批发管理后台</title>
  <?php 
  include("common/conn.php"); 
  include("./tool/UpFileTool.class.php");
  if($_SESSION['userid']==""){echo "<script>window.location.href='login.php';</script>";} 

  if($_GET['action']=="ok")
{ 
  mysql_query("insert into orders_first(catename,cateid,first_cate_rate,first_cate_use) values('$_REQUEST[allName]','$_REQUEST[categroy]','$_REQUEST[cate_rate]','$_REQUEST[cate_use]') ");
echo "<script>window.location.href='ordersFirst.php';</script>";
}

if($_GET['id']!=""){
  $rert30=mysql_query("select * from orders_first where id='".$_GET['id']."'");
  $sdg3=mysql_fetch_assoc($rert30);
}

  $que=mysql_query('select * from categroy');
  while( $sdg30=mysql_fetch_assoc($que) ){
    $rowsb[]=$sdg30;
  }

if($_GET['ch']=="ok")
{
  if($_REQUEST['categroy'] == '') {
    $_REQUEST['categroy'] = 0;
  }

  $sql = "update orders_first set cateid='".$_REQUEST['categroy']."',catename='".$_REQUEST['allName']."', first_cate_rate=".$_REQUEST['cate_rate'].", first_cate_use='".$_REQUEST['cate_use']."' where id=".$_REQUEST['id'];
  $res = mysql_query($sql);
echo "<script>window.location.href='ordersFirst.php';</script>";
}


?>
<script type="text/javascript" src="js/jquery.min.js"></script>

<!-- MASTER STYLESHEET-->
<link href="css/styles.css" rel="stylesheet" type="text/css" />
<script src="js/graphs.js" type="text/javascript"></script>


</head>

<body>

  <!--header-->
  <?php include("common/header.php");?>
  <!--header end-->


  <!-- staqrt subnav -->
  <div id="sub_nav">

    <div id="subnav_wrap" class="container_12">
      <div id="subnav" class=" grid_12">

        <ul>
          <li> <a href="fenlei.php"> 分类管理 </a></li>
          <li> <a href="fenlei_leixing.php"> 分类属性 </a></li>
          <li><a href="ordersFirst.php" class="sub_nav_active" >首单返券</a></li>
        </ul>

      </div>

    </div>


  </div>

  <div class="container_12">
    <form action="?<?php if($_GET['id']!=""){echo "ch=ok";}else{echo "action=ok";} ?>" method="post"  enctype="multipart/form-data" >
      <h2>添加使用分类</h2>  	
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
      <?php if(!$_GET['q']){ ?>
          <tr>
            <th width="" scope="col">类别选择</th>
            <th width="" scope="col">
              <select name="categroy">
                <option selected value="">选择分类</option>}
                             option             
                <?php foreach($rowsb as $vr){?>
                <option <?php if($vr[cateid]==$sdg3[cateid]){echo 'selected';} ?> value="<?php echo $vr[cateid] ?>" ><?php echo $vr['name'] ?></option>
                <?php }?>                      
              </select>
            </th>
          </tr>
      <?php } ?>
          <tr>
            <th width="20%" scope="col">分类名称</th>
            <th width="20%" scope="col">
            <input type="text" <?php if($_GET['q']){ echo 'readonly';} ?> name="allName" value="<?php echo $sdg3[catename] ?>"/>
            </th>
          </tr>
          
          <tr>
            <th width="20%" scope="col">首单返券比率</th>
            <th width="20%" scope="col"><input type="text" name="cate_rate" value="<?php echo $sdg3[first_cate_rate] ?>"/> %</th>
          </tr>
       
          <tr>
            <th width="20%" scope="col">返券使用比率</th>
            <th width="20%" scope="col"><input type="text" name="cate_use" value="<?php echo $sdg3[first_cate_use] ?>"/> %</th>
          </tr>
       
        <tr>
          <th width="" colspan="2" scope="col">
          <input name="id" type="text" value="<?php echo $_GET[id];?>" />
          <input name="" class="submit" type="submit" value="提交" /></th>
        </tr>


      </table>
    </form>          
  </div>
</form>
</body>
</html>
